<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class history extends CI_Controller {
	var $data;
	public function __construct()
	{
		parent::__construct();		
		$this->load->library('session');
		$this->load->library('pagination');
		$data['title'] = "Companies";		
		$this->load->model('model_history');
		$this->load->model('model_user');
		// CHECK LOGIN
		$check = $this->session->userdata('login');
		if($check==false){
			redirect(base_url().'login/', 'refresh');
			return;
		}
	}
	
	public function index()
	{
		$this->view();
	}

	public function view($paging=0){
		if($paging<0){
			$paging=0;
		}
		
		$this->data["set_page"] 	= 'history_list';


		$user_id	=$this->input->get("user_id");
		$where	=$this->input->get("where");

		$order_by="his_id DESC";
		//$comp_status=$_POST["comp_status"];
		
		$array_parent_id = $this->session->userdata('parentId');
		$this->data["result_user"] 		= $this->model_user->select(array("array_uId"=>$array_parent_id));

		$this->data["result"] 		= $this->model_history->select(array("user_id"=>$user_id,"where"=>$where,"order_by"=>$order_by,"array_uId"=>$array_parent_id,'limit'=>10,'paging'=>$paging));
		//}		
		$this->data["count_page"]	 = $this->model_history->select(array("user_id"=>$user_id,"where"=>$where,"array_uId"=>$array_parent_id));
		//$this->load->view('history', $this->data);
        $this->load->view('qt/history_list', $this->data);
	}

}

